<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
     <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>

</head>
<body>
	
	<script src='${pageContext.request.contextPath}/static/lib/jquery-2.1.4.min.js'></script>
	
	<h1>管理考试成绩</h1>
	<div style="width:100%;margin-top:15px">
		<h4>查询条件</h4>
		科目：
		<select id="subjects">
			<option value="">请选择</option>
			<c:forEach items="${examSubject }" var="subject">
				<option value="${subject.subId }">${subject.name }</option>
			</c:forEach>
		</select>&nbsp&nbsp
		学号：<input type="text" id="studentId"/>&nbsp&nbsp
		姓名：<input type="text" id="studentName"/>&nbsp&nbsp
		考试日期：<input type="text" id="testTime"/>&nbsp&nbsp
		<button type="button" style="background-color:#87b87f" id="isok">开始查询</button>
	</div>
	
	<h4><b>查询结果</b></h4>
	<table id="sample-table-1" class="table table-striped table-bordered table-hover" style="margin-top:15px">
		<thead>
			<tr>
				<th>学号</th>
				<th>姓名</th>
				<th>考试科目</th>
				<th>考试时间</th>
				<th>考试分数</th>
			</tr>
		</thead>
		<tbody id="tbody">
			<c:forEach items="${studentScoreList }" var="studentScore">
				<tr>
					<td>${studentScore.studentId }</td>
					<td>${studentScore.studentName }</td>
					<td>${studentScore.examSubject }</td>
					<td>${studentScore.testTime }</td>
					<td>${studentScore.examScore }</td>
				</tr>
			</c:forEach>
		</tbody>
	</table>
	<script src="${pageContext.request.contextPath}/static/lib/jquery-ui.min.js"></script>
	<script>
  $(function() {
		$( "#testTime" ).datepicker({
		      showWeek: false,
		      firstDay: 1
		 });
		$("#testTime").datepicker('option', {dateFormat: 'yy-mm-dd'});
	})
    
  </script>
  
  <!--查询  -->
  <script type="text/javascript">
  $(document).ready(function() {
	  
		$("#isok").click(function(){
			var subjectId = $("#subjects").val();
			var studentName = $("#studentName").val();
			var studentId = $("#studentId").val();
			var testTime = $("#testTime").val();
			
			if(subjectId == "" && studentId == "" && studentName == "" && testTime == ""){
				alert("至少选择一个查询条件！");
				return false;
			}
			
			$.ajax({
				type : 'POST',
				url : 'FindManageGrade',
				data : {
					"subjectId":subjectId,
					"studentId":studentId,
					"studentName":studentName,
					"testTime":testTime
						},
				async : false,
				dataType : 'json',
				success : function(data) {
					var src = '';
					if(data != null){
						for ( var count in data) {
							src += '<tr><td>' + data[count].studentId + '</td><td>'+data[count].studentName+'</td><td>'+data[count].examSubject+'</td><td>'+
							data[count].testTime+'</td><td>'+ data[count].examScore + '</td></tr>'
						}
						$("#tbody").html(src);
					}
					
				}
			});
					
		});
		
	});
  </script>
  
</body>
</html>